home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / win_q_t / trem.zip / SIZE.C < prev    next >
Text File  |  1991-05-11  |  3KB  |  81 lines

  1. /************************************************************************
  2.  *
  3.  *    Copyright (c) 1991 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *-----------------------------------------------------------------------
  6.  *
  7.  *     Project:  Windows Terminal Example
  8.  *
  9.  *      Module:  size.c
  10.  *
  11.  *      Author:  Bryan A. Woodruff (baw)
  12.  *
  13.  *
  14.  *     Remarks:  Handles the sizing of the terminal window
  15.  *
  16.  *   Revisions:
  17.  *     01.00.000  5/ 8/91 baw   Wrote it
  18.  *
  19.  ************************************************************************/
  20.  
  21. #include "terminal.h"
  22.  
  23. /************************************************************************
  24.  *  BOOL SizeTerminal( HWND hWnd, WORD wVertSize, WORD wHorzSize )
  25.  *
  26.  *  Description:
  27.  *     Sizes terminal and sets up scrolling regions
  28.  *
  29.  *  Comments:
  30.  *      5/ 8/ 91  baw  Wrote it
  31.  *
  32.  ************************************************************************/
  33.  
  34. BOOL SizeTerminal( HWND hWnd, WORD wVertSize, WORD wHorzSize )
  35. {
  36.    int          nScrollAmt ;
  37.    LOCALHANDLE  hTermInfo ;
  38.    NPTERMINFO   npTermInfo ;
  39.  
  40.    hTermInfo = GetWindowWord( hWnd, GWW_TERMINFO ) ;
  41.    if (NULL == (npTermInfo = (NPTERMINFO) LocalLock( hTermInfo )))
  42.       return ( FALSE ) ;
  43.  
  44.    if (npTermInfo -> ySize != (int) wVertSize)
  45.    {
  46.       npTermInfo -> ySize = (int) wVertSize ;
  47.       npTermInfo -> yScroll = max( 0, (MAXROWS * npTermInfo -> yChar) -
  48.                                    npTermInfo -> ySize ) ;
  49.       nScrollAmt = min( npTermInfo -> yScroll, npTermInfo -> yOffset ) -
  50.                         npTermInfo -> yOffset ;
  51.       ScrollWindow( hWnd, 0, -nScrollAmt, NULL, NULL ) ;
  52.  
  53.       npTermInfo -> yOffset = npTermInfo -> yOffset + nScrollAmt ;
  54.       SetScrollPos( hWnd, SB_VERT, npTermInfo -> yOffset, FALSE ) ;
  55.       SetScrollRange( hWnd, SB_VERT, 0, npTermInfo -> yScroll, TRUE ) ;
  56.       InvalidateRect( hWnd, NULL, TRUE ) ;
  57.    }
  58.    if (npTermInfo -> xSize != (int) wHorzSize)
  59.    {
  60.       npTermInfo -> xSize = (int) wHorzSize ;
  61.       npTermInfo -> xScroll = max( 0, (MAXCOLS * npTermInfo -> xChar) -
  62.                                    npTermInfo -> xSize ) ;
  63.       nScrollAmt = min( npTermInfo -> xScroll, npTermInfo -> xOffset) -
  64.                         npTermInfo -> xOffset ;
  65.       ScrollWindow( hWnd, 0, -nScrollAmt, NULL, NULL ) ;
  66.       npTermInfo -> xOffset = npTermInfo -> xOffset + nScrollAmt ;
  67.       SetScrollPos( hWnd, SB_HORZ, npTermInfo -> xOffset, FALSE ) ;
  68.       SetScrollRange( hWnd, SB_HORZ, 0, npTermInfo -> xScroll, TRUE ) ;
  69.       InvalidateRect( hWnd, NULL, TRUE ) ;
  70.    }
  71.  
  72.    LocalUnlock( hTermInfo ) ;
  73.    return ( TRUE ) ;
  74.  
  75. } /* end of SizeTerminal() */
  76.  
  77. /************************************************************************
  78.  * End of File: size.c
  79.  ************************************************************************/
  80.  
  81.